<?php 

// $postid is avalable here
$vote_select_res =  mysql_query("SELECT * FROM site_votes WHERE `target`='$voteid' AND `user`='$user'");
if(mysql_numrows($vote_select_res)!=0) 
$vote_select = mysql_result($vote_select_res,0,'vote');
else $vote_select = "0";

$output=$output.'<div class="tri_up_vote voteup';
if($vote_select == "1") $output=$output." voteselect "; 
else $output=$output." votearrow ";
 
$output=$output.'" id="voteup_'.$voteid.'" ></div>';
$output=$output.'<div id="votecount_'.$voteid.'" class="vote_counter" style="text-align:center;font-size:12pt;margin:5px;opacity:0.3">';

$positive = mysql_numrows(mysql_query("SELECT * FROM site_votes WHERE  `target`='$voteid' AND `vote`='1'"));
$negative = mysql_numrows(mysql_query("SELECT * FROM site_votes WHERE  `target`='$voteid' AND `vote`='-1'"));

$output=$output.((int)$positive - (int)$negative).'</div>';
$output=$output.'<div class="tri_down_vote votedown';
if($vote_select == "-1") $output=$output." voteselect "; 
else $output=$output." votearrow ";

$output=$output.'" id="votedown_'.$voteid.'" ></div>';  

?>